package com.p2p.front.service.impl;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.p2p.base.exception.BizException;
import com.p2p.base.util.MD5Util;
import com.p2p.front.service.CommonService;
import com.p2p.user.facade.UserQueryFacade;
import com.p2p.user.result.UserQueryResult;

/**
 * leiwen@yiqihao.com
 */
@Service("commonService")
public class CommonServiceImpl implements CommonService {

	@Resource
	private UserQueryFacade userQueryFacade;
	
	
	@Override
	public boolean checkPaypwd(String paypwd,Long uid){
		UserQueryResult userResult = userQueryFacade.getUserInfoById(uid+"");
		if (!userResult.isSuccess()) {
			throw new BizException("user_error", "查询用户信息失败");
		}
		String realPaypwd = userResult.getUserInfoFullVO().getPaypwd();
		if (StringUtils.isNotEmpty(realPaypwd)) {
			String inPwd = MD5Util.sha1(paypwd);
			if (!inPwd.equals(realPaypwd)) {
				//throw new BizException("paypwd_error", "支付密码不正确");
				return false;
			}
		}
		return true;
	}
}
